//
//  BaseTableViewController.swift
//  ChargeManager
//
//  Created by solarke_apple_mini_1 on 16/9/2.
//  Copyright © 2016年 石家庄科林电气股份有限公司. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController{
    // MARK: - IBAction
    @IBAction func backButtonPressed() {
        navigationController?.popViewController(animated: true)
    }
    
    // MARK: - Function
    func handleError(_ error: NSError!, defaultText: String = "网络错误，请稍候重试") {
        let string = error.userInfo[NSLocalizedDescriptionKey] as? String
        let text = string ?? defaultText
        showToast(text)
    }
    
    // MARK: - BuiltIn
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        // 检查存储桶
        let name = NSStringFromClass(self.classForCoder)
        let key = "__\(name)"
        let data = Bucket.defaultBucket().bucketOut(key)
        if data != nil {
            viewControllerWillPresent(data!)
        }
    }
    
    func viewControllerWillPresent(_ data: AnyObject) {
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}
